package zhihui.mobile.presenter.shop;

import android.content.Context;
import android.content.Intent;

import java.util.ArrayList;
import java.util.List;

import zhihui.mobile.bean.shop.SkuInfo;
import zhihui.mobile.bean.shop.sales.SalesShopInfo;
import zhihui.mobile.manager.shop.ShopOrderManager;
import zhihui.mobile.manager.shop.ShopSalesManager;
import zhihui.mobile.ui.IView;
import zhihui.mobile.ui.shop.order.ShopOrderConfirmActivity;
import zhihui.mobile.ui.shop.sales.IShopSalesContract;

/**
 * Created by 张公铭 on 2017/8/2 0002.
 */

public class ShopSalesPresenter implements IShopSalesContract.IShopSalesPresenter
{
    private Context mContext;
    private IShopSalesContract.IShopSalesView salesView;

    @Override
    public void init(IView view, Context context)
    {
        mContext = context;
        salesView = (IShopSalesContract.IShopSalesView) view;
    }

    @Override
    public void onResume()
    {
    }

    @Override
    public void onStart()
    {

    }

    @Override
    public void onPause()
    {

    }

    @Override
    public void onStop()
    {

    }

    @Override
    public void onDestroy()
    {

    }

    @Override
    public void initData()
    {
        salesView.initDataView(ShopSalesManager.getInstance().getmList());
    }

    @Override
    public void goConfirmOrder(SalesShopInfo shopInfo, int salesId)
    {
        salesView.showLoading();
        List<SkuInfo> list = new ArrayList<>();
        SkuInfo skuInfo = new SkuInfo();
        skuInfo.setSkuId(shopInfo.getId());
        skuInfo.setNum(1);
        skuInfo.setThumbnail(shopInfo.getThumbnail());
        skuInfo.setTitle(shopInfo.getTitle());
        skuInfo.setPrice(shopInfo.getAmount());
        skuInfo.setSpecif("");
        list.add(skuInfo);
        ShopOrderManager.getInstance().setConfirmList(list);
        Intent intent = new Intent(mContext, ShopOrderConfirmActivity.class);
        intent.putExtra("salesId", salesId);
        mContext.startActivity(intent);
        salesView.hindLoading();
    }
}
